<?

include($_SERVER['DOCUMENT_ROOT'].'/portals/config.php');
include($_SERVER['DOCUMENT_ROOT'].'/groups/database.php');




$sql = array();
$sql['columns'] = 'COUNT(*)';
$sql['wheres'] = array();
$sql['tables'][] = "portal";
$sql['wheres'] = array();

$sql['wheres'][] = "domain = ".dbQuote($_GET['domain']);

if (!empty($_GET['id'])) {
	$sql['wheres'][] = "portal_id != ".intval($_GET['id']);

}



$query = sqlMakeQuery($sql);



if (!empty($_GET['callback'])) {
        $callback = preg_replace('/[^\w\.-]+/','',$_GET['callback']);
        echo "{$callback}(";
}

if (getOne($query)) {
	print "'Taken! Choose another...'";
} else {
	print "'available...'";
}

if (!empty($_GET['callback'])) {
        echo ");";
}

